package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class ReturnOperation implements IOPeration {
    @Override
    public void work(BookList bookList) {
        System.out.println("归还图书");

        System.out.println("你要归还的书籍名称是：");
        Scanner scanner = new Scanner(System.in);
        String bookName = scanner.nextLine();

        int number = bookList.getUsedSize();
        for (int i = 0; i < number; i++) {
            Book book = bookList.getBook(i);
            if(book.getName().equals(bookName)) {
                book.setLend(false);
                System.out.println("归还成功");
                return;
            }
        }
        System.out.println("归还失败");
    }
}
